#pragma once
#include <iostream>
#include <vector>
#include <string>
#include <arpa/inet.h>
#include <json/json.h>
#include <arpa/inet.h>

#ifndef __ControlConn__
#define __ControlConn__
#define IP_SERVER "127.0.0.1"
#define PORT_SERVER 30002

struct ControlConn {
	ControlConn() {
		addr.sin_family = AF_INET;
		addr.sin_port = htons(PORT_SERVER);
		inet_pton(AF_INET, IP_SERVER, &addr.sin_addr.s_addr);
		fd = socket(AF_INET, SOCK_STREAM, 0);
	}
	ControlConn(const char* ip) {
		addr.sin_family = AF_INET;
		addr.sin_port = htons(PORT_SERVER);
		inet_pton(AF_INET, ip, &addr.sin_addr.s_addr);
		fd = socket(AF_INET, SOCK_STREAM, 0);
	}
	ControlConn(const char* ip, int port) {
		addr.sin_family = AF_INET;
		addr.sin_port = htons(port);
		inet_pton(AF_INET, ip, &addr.sin_addr.s_addr);
		fd = socket(AF_INET, SOCK_STREAM, 0);
	}
	sockaddr_in addr;
	int fd;
};
#endif

#ifndef __ControlMsg__
#define __ControlMsg__
class ControlMsg {
public:
	ControlMsg();
	ControlMsg(int);
	ControlMsg(int, std::string);
	friend std::ostream & operator<<(std::ostream & os, const ControlMsg& msg);
public:
	int droneNumber;
	std::vector<double> position;
	std::string mode;
};

#endif


#ifndef __DroneState__
#define __DroneState__
class DroneState {
public:
	DroneState();
public:
	int DroneNumber;
	std::vector<double> acceleration;
	std::vector<double> position;
	std::vector<double> orientation;
	std::vector<double> velocity;
	std::string mode;
	std::string bridgeMessage;
};
#endif



#ifndef __Client__
#define __Client__

class Client
{
public:
	void sendMsg(std::vector<ControlMsg>& controlVec);
	void refresh();
	int recvMsg(std::vector<DroneState> &);
	Client(int fileDescriper, sockaddr_in * arg);
	Client();
	int fd;
private:
	sockaddr_in* addr;

};
#endif

